package com.ruoyi.campus.service.impl;

import com.ruoyi.campus.domain.Campusdistriapply;
import com.ruoyi.campus.domain.vo.CampusdistriapplyVO;
import com.ruoyi.campus.mapper.CampusdistriapplyMapper;
import com.ruoyi.campus.service.ICampusdistriapplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 分销校区申请列表Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-06-12
 */
@Service
public class CampusdistriapplyServiceImpl implements ICampusdistriapplyService 
{
    @Autowired
    private CampusdistriapplyMapper campusdistriapplyMapper;

    /**
     * 查询分销校区申请列表
     * 
     * @param applyDistributionId 分销校区申请列表主键
     * @return 分销校区申请列表
     */
    @Override
    public Campusdistriapply selectCampusdistriapplyByApplyDistributionId(Integer applyDistributionId)
    {
        return campusdistriapplyMapper.selectCampusdistriapplyByApplyDistributionId(applyDistributionId);
    }

    /**
     * 查询分销校区申请列表列表
     * 
     * @param campusdistriapplyvo 分销校区申请列表
     * @return 分销校区申请列表
     */
    @Override
    public List<CampusdistriapplyVO> selectCampusdistriapplyList(CampusdistriapplyVO campusdistriapplyvo)
    {
        return campusdistriapplyMapper.selectCampusdistriapplyList(campusdistriapplyvo);
    }


    // /**
    //  * 查询分销校区申请列表列表
    //  *
    //  * @param campusdistriapply 分销校区申请列表
    //  * @return 分销校区申请列表
    //  */
    // @Override
    // public List<Campusdistriapply> selectCampusdistriapplyList(Campusdistriapply campusdistriapply)
    // {
    //     return campusdistriapplyMapper.selectCampusdistriapplyList(campusdistriapply);
    // }




    /**
     * 新增分销校区申请列表
     * 
     * @param campusdistriapply 分销校区申请列表
     * @return 结果
     */
    @Override
    public int insertCampusdistriapply(Campusdistriapply campusdistriapply)
    {
        return campusdistriapplyMapper.insertCampusdistriapply(campusdistriapply);
    }

    /**
     * 修改分销校区申请列表
     * 
     * @param campusdistriapply 分销校区申请列表
     * @return 结果
     */
    @Override
    public int updateCampusdistriapply(Campusdistriapply campusdistriapply)
    {
        return campusdistriapplyMapper.updateCampusdistriapply(campusdistriapply);
    }

    /**
     * 批量删除分销校区申请列表
     * 
     * @param applyDistributionIds 需要删除的分销校区申请列表主键
     * @return 结果
     */
    @Override
    public int deleteCampusdistriapplyByApplyDistributionIds(Integer[] applyDistributionIds)
    {
        return campusdistriapplyMapper.deleteCampusdistriapplyByApplyDistributionIds(applyDistributionIds);
    }

    /**
     * 删除分销校区申请列表信息
     * 
     * @param applyDistributionId 分销校区申请列表主键
     * @return 结果
     */
    @Override
    public int deleteCampusdistriapplyByApplyDistributionId(Integer applyDistributionId)
    {
        return campusdistriapplyMapper.deleteCampusdistriapplyByApplyDistributionId(applyDistributionId);
    }

    @Override
    public int distribute(CampusdistriapplyVO campusdistriapplyVO) {
        String s = campusdistriapplyVO.getIsDistribute();
        System.out.println(campusdistriapplyVO);
        System.out.println(s);
        if(s.equals("1")){
            campusdistriapplyMapper.updateCampusCampusIsRecommended(campusdistriapplyVO.getCampusId(),0);
        }else {
            campusdistriapplyMapper.updateCampusCampusIsRecommended(campusdistriapplyVO.getCampusId(),1);
        }

        return campusdistriapplyMapper.distribute(campusdistriapplyVO);
    }
}
